
#ifndef __SINKER_ERROR_HPP_2010__
#define __SINKER_ERROR_HPP_2010__

#include    <cstdio>
#include    <cstdarg>

// if use QLOG or not
#define	USE_QLOG

#ifdef	USE_QLOG
#include	"qlog.h"
#endif

#define	CAT_NMAP	"NMAP"
#define	CAT_NMAP_METER	"NMETER"
#define	CAT_NMAP_METER_PAGE	"NMTR_PAGE"
#define	CAT_NMAP_METER_SE	"NMTR_SE"
#define	CAT_NMAP_METER_CSSC	"NMTR_CSSC"
#define	CAT_NMAP_METER_PEARSON	"NMTR_PEARSON"
#define	CAT_DISTRIBUTOR	"DISTRIBUTOR"
#define	CAT_DISTRIBUTOR_METER	"DMETER"
#define	CAT_STAGE	"STAGE"
#define	CAT_STORAGE	"WBNG.STORAGE"
#define	CAT_WEB		"WEB"
#define	CAT_SINKER	"SINKER"


#define	CAT_STAT_DISTRIBUTOR	"wbng.stat.dist"
#define	CAT_STAT_DIST			"wbng.stat.dist"
#define	CAT_STAT_SINK			"wbng.stat.sink"
#define	CAT_STAT_STORE			"wbng.stat.store"
#define	CAT_METER_DIST           "wbng.stat.meter.dist"

#ifdef	USE_QLOG
	#define	ERROR(category, error, fmt, args...)	qAppError(category, fmt, ##args )
	#define	INFO(category, fmt, args...)	qLogInfo(category, fmt, ##args )
	#define	DEBUG(category, fmt, args...)	qLogDebug(category, fmt, ##args )
	#define	TRACE(category, fmt, args...)	qLogTrace(category, fmt, ##args )

	#define	isDebugable(category)	QPub::isLog(category, QPub::DEBUG)
	#define	isTraceable(category)	QPub::isLog(category, QPub::TRACE)

#else
	#define ERROR(category, errorno, pszFormat, args...)   fprintf(stderr,"%s %d %s [%s] ERROR ", __FILE__, __LINE__, __func__, category),fprintf(stderr, pszFormat"\n", ##args)
	#define INFO(category, pszFormat, args...)   fprintf(stderr,"%s %d %s [%s] INFO ", __FILE__, __LINE__, __func__, category),fprintf(stderr, pszFormat"\n", ##args)

#ifdef	__DEBUG__
	#define DEBUG(category, pszFormat, args...)   fprintf(stderr,"%s %d %s [%s] DEBUG ", __FILE__, __LINE__, __func__, category),fprintf(stderr, pszFormat"\n", ##args)
	#define TRACE(category, pszFormat, args...)   fprintf(stderr,"%s %d %s [%s] TRACE ", __FILE__, __LINE__, __func__, category),fprintf(stderr, pszFormat"\n", ##args)

	#define	isDebugable(category)		true
	#define	isTraceable(category)		true
#else
	#define DEBUG(category, pszFormat, args...)   (void)NULL
	#define TRACE(category, pszFormat, args...)   (void)NULL

	#define	isDebugable(category)		false
	#define	isTraceable(category)		false
#endif
#endif


////////////////////////////////////////////////////////////////////////
//  ERROR CODE
#define	WB_EBASE	-10000

#define	WB_EINV                  (WB_EBASE + 1)
#define	WB_ESMALLBUF             (WB_EBASE + 2)
#define	WB_EBADNAME              (WB_EBASE + 3)
#define	WB_EALLOC                (WB_EBASE + 4)
#define	WB_ETRUNC                (WB_EBASE + 5)
#define	WB_EOVERFLOW             (WB_EBASE + 6)
#define	WB_EUNDERFLOW            (WB_EBASE + 7)
#define WB_ESMALLTAGBUF          (WB_EBASE + 8)

#define	WB_EDIST_NMAP            (WB_EBASE + 11)
#define	WB_EDIST_TRANS           (WB_EBASE + 12)

#define	WB_ETODO                 (WB_EBASE + 100)

#endif  /* __SINKER_ERROR_HPP_2010__ */
